﻿using LibNoise;
using LibNoise.Generator;
using UnityEngine;
using Zzzxl.Util;

public class Terrain : MonoBehaviour {
    public static byte GetTerrainBlock (Vector3i position, Perlin perlin, int seed) {
        Random.InitState (seed);
        float newPos = Random.value * 10000;
        Vector3 offset = new Vector3 (newPos, newPos, newPos);

        float noiseX = Mathf.Abs ((position.x + offset.x) / 20);
        float noiseY = Mathf.Abs ((position.y + offset.y) / 20);
        float noiseZ = Mathf.Abs ((position.z + offset.z) / 20);
        double noise = perlin.GetValue (noiseX, noiseY, noiseZ);

        noise += (20 - position.y) / 15f;
        noise /= position.y / 5f;

        if (noise > 0.5f) return 1;
        return 0;
    }
}